package shop.xiaosa.service.impl;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import shop.xiaosa.mapper.UserMapper;
import shop.xiaosa.pojo.User;
import shop.xiaosa.service.UserService;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User login(@Param(value = "phone") String phone,@Param(value = "password") String password) {
        User user = userMapper.login(phone, password);
        if (user==null){
            return null;
        }

        return user;
    }

    @Override
    public boolean add(User user) {
        if (user!=null){
            if (userMapper.insert(user)==1){
                return true;
            }
        }
        return false;
    }

    @Override
    public List<User> findAll() {
        return userMapper.selectAll();
    }
}
